﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminSite.Master" AutoEventWireup="true" CodeBehind="quanlychuyenmuc.aspx.cs" Inherits="WebRaoVat.Admin.QuanLyChuyenMuc" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<div id="blockright">
        <div id="box-pro-highlights-main">
		<div class="content">
        	<div class="box-pro-highlights-main-header">
			    [Chuyên mục] Cập nhật dữ liệu danh mục vào file XML
            </div>
                <div style="float:left">
                <asp:Button ID="Button3" runat="server" Text="Cập nhật" 
                onclick="Button3_Click" />
                </div>
            </div>
            </div>
		 <div id="box-pro-highlights-main">
		<div class="content">
        	<div class="box-pro-highlights-main-header">
			    Quản lý chuyên mục chính
            </div>
            <div>
		    
             <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                 AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="MaDanhMucChinh" 
                 DataSourceID="SqlDataSource3">
                 <Columns>
                     <asp:CommandField ShowEditButton="True" 
                         ShowInsertButton="True" InsertText="" NewText="" CancelText="Hủy" UpdateText="Cập nhật" EditText="Sửa" />
                     <asp:BoundField DataField="MaDanhMucChinh" HeaderText="MaDanhMucChinh" 
                         ReadOnly="True" SortExpression="MaDanhMucChinh" />
                     <asp:BoundField DataField="TenDanhMucChinh" HeaderText="TenDanhMucChinh" 
                         SortExpression="TenDanhMucChinh" />
                     <asp:TemplateField HeaderText="ThuTu" SortExpression="ThuTu">
                         <EditItemTemplate>
                             <asp:DropDownList ID="DropDownList8" runat="server"
                                DataValueField="ThuTu"
                                SelectedValue='<% # Bind("ThuTu") %>'>
                                 <asp:ListItem>-1</asp:ListItem>
                                 <asp:ListItem>1</asp:ListItem>
                                 <asp:ListItem>2</asp:ListItem>
                                 <asp:ListItem>3</asp:ListItem>
                                 <asp:ListItem>4</asp:ListItem>
                                 <asp:ListItem>5</asp:ListItem>
                                 <asp:ListItem>6</asp:ListItem>
                                 <asp:ListItem>7</asp:ListItem>
                                 <asp:ListItem>8</asp:ListItem>
                                 <asp:ListItem>9</asp:ListItem>
                                 <asp:ListItem>10</asp:ListItem>
                                 <asp:ListItem>11</asp:ListItem>
                                 <asp:ListItem>12</asp:ListItem>
                                 <asp:ListItem>13</asp:ListItem>
                                 <asp:ListItem>14</asp:ListItem>
                                 <asp:ListItem>15</asp:ListItem>
                             </asp:DropDownList>
                         </EditItemTemplate>
                         <HeaderTemplate>
                             Thứ tự
                         </HeaderTemplate>
                         <ItemTemplate>
                             <asp:DropDownList ID="DropDownList7" runat="server"
                             DataValueField="ThuTu"
                                SelectedValue='<% # Bind("ThuTu") %>' Enabled="false">
                                 <asp:ListItem>-1</asp:ListItem>
                                 <asp:ListItem>1</asp:ListItem>
                                 <asp:ListItem>2</asp:ListItem>
                                 <asp:ListItem>3</asp:ListItem>
                                 <asp:ListItem>4</asp:ListItem>
                                 <asp:ListItem>5</asp:ListItem>
                                 <asp:ListItem>6</asp:ListItem>
                                 <asp:ListItem>7</asp:ListItem>
                                 <asp:ListItem>8</asp:ListItem>
                                 <asp:ListItem>9</asp:ListItem>
                                 <asp:ListItem>10</asp:ListItem>
                                 <asp:ListItem>11</asp:ListItem>
                                 <asp:ListItem>12</asp:ListItem>
                                 <asp:ListItem>13</asp:ListItem>
                                 <asp:ListItem>14</asp:ListItem>
                                 <asp:ListItem>15</asp:ListItem>
                             </asp:DropDownList>
                         </ItemTemplate>
                     </asp:TemplateField>

                     
                     
                     <asp:TemplateField HeaderText="Deleted">
                         <EditItemTemplate>
                             <asp:DropDownList ID="Deleted" runat="server" DataValueField="Deleted"
                                SelectedValue='<% # Bind("Deleted") %>'>
                                 <asp:ListItem>0</asp:ListItem>
                                 <asp:ListItem>1</asp:ListItem>
                             </asp:DropDownList>
                         </EditItemTemplate>
                         <HeaderTemplate>
                             Đã xóa
                         </HeaderTemplate>
                         <ItemTemplate>
                             <asp:DropDownList ID="DropDownList1" runat="server" 
                                 SelectedValue='<% # Bind("Deleted") %>' Enabled="False">
                                 <asp:ListItem>0</asp:ListItem>
                                 <asp:ListItem>1</asp:ListItem>
                             </asp:DropDownList>
                         </ItemTemplate>
                     </asp:TemplateField>
                     
                     
                 </Columns>
             </asp:GridView>
		    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConflictDetection="CompareAllValues" 
                ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
                DeleteCommand="DELETE FROM [DANHMUCCHINH] WHERE [MaDanhMucChinh] = @original_MaDanhMucChinh AND (([TenDanhMucChinh] = @original_TenDanhMucChinh) OR ([TenDanhMucChinh] IS NULL AND @original_TenDanhMucChinh IS NULL)) AND (([ThuTu] = @original_ThuTu) OR ([ThuTu] IS NULL AND @original_ThuTu IS NULL)) AND (([Deleted] = @original_Deleted) OR ([Deleted] IS NULL AND @original_Deleted IS NULL))" 
                InsertCommand="INSERT INTO [DANHMUCCHINH] ([TenDanhMucChinh], [ThuTu], [Deleted]) VALUES (@TenDanhMucChinh, @ThuTu, @Deleted)" 
                OldValuesParameterFormatString="original_{0}" 
                ProviderName="System.Data.SqlClient" 
                SelectCommand="SELECT * FROM [DANHMUCCHINH]" 
                UpdateCommand="UPDATE [DANHMUCCHINH] SET [TenDanhMucChinh] = @TenDanhMucChinh, [ThuTu] = @ThuTu, [Deleted] = @Deleted WHERE [MaDanhMucChinh] = @original_MaDanhMucChinh AND (([TenDanhMucChinh] = @original_TenDanhMucChinh) OR ([TenDanhMucChinh] IS NULL AND @original_TenDanhMucChinh IS NULL)) AND (([ThuTu] = @original_ThuTu) OR ([ThuTu] IS NULL AND @original_ThuTu IS NULL)) AND (([Deleted] = @original_Deleted) OR ([Deleted] IS NULL AND @original_Deleted IS NULL))">
                <DeleteParameters>
                    <asp:Parameter Name="original_MaDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="original_TenDanhMucChinh" Type="String" />
                    <asp:Parameter Name="original_ThuTu" Type="Int32" />
                    <asp:Parameter Name="original_Deleted" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="TenDanhMucChinh" Type="String" />
                    <asp:Parameter Name="ThuTu" Type="Int32" />
                    <asp:Parameter Name="Deleted" Type="Int32" />
                    <asp:Parameter Name="original_MaDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="original_TenDanhMucChinh" Type="String" />
                    <asp:Parameter Name="original_ThuTu" Type="Int32" />
                    <asp:Parameter Name="original_Deleted" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="TenDanhMucChinh" Type="String" />
                    <asp:Parameter Name="ThuTu" Type="Int32" />
                    <asp:Parameter Name="Deleted" Type="Int32" />
                </InsertParameters>
            </asp:SqlDataSource>
		   </div>
		   <div style="float:left">
               <asp:Label ID="Label1" runat="server" Text="Tên danh mục chính"></asp:Label>
               <asp:TextBox ID="txtTenDanhMucChinh" runat="server"></asp:TextBox>
               <asp:Button ID="Button1" runat="server" Text="Thêm mới" 
                   onclick="Button1_Click"/>
		   </div>
		</div>
		</div>
		
		<div id="box-pro-highlights-main">
		<div class="content">
        	<div class="box-pro-highlights-main-header">
			    Quản lý chuyên mục con
            </div>
            <div>
            <asp:GridView ID="GridView2" runat="server" AllowPaging="True" 
                AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="MaDanhMucCon" 
                DataSourceID="SqlDataSource1" onrowupdating="GridView2_RowUpdating">
                <Columns>
                    <asp:CommandField ShowEditButton="True" CancelText="Hủy" UpdateText="Cập nhật" EditText="Sửa" />
                    <asp:BoundField DataField="MaDanhMucCon" HeaderText="MaDanhMucCon" 
                        InsertVisible="False" ReadOnly="True" SortExpression="MaDanhMucCon" />
                    <asp:BoundField DataField="TenDanhMucCon" HeaderText="TenDanhMucCon" 
                        SortExpression="TenDanhMucCon" />
                        
                    <asp:TemplateField HeaderText="TenDanhMucChinh" 
                        SortExpression="TenDanhMucChinh">
                        <EditItemTemplate>
                            
                            <asp:DropDownList ID="DropDownList6" runat="server" 
                                DataSourceID="SqlDataSource1" DataTextField="TenDanhMucChinh"
                                DataValueField="TenDanhMucChinh" SelectedValue='<% # Bind("TenDanhMucChinh") %>'>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
                                ProviderName="System.Data.SqlClient" 
                                SelectCommand="SELECT [TenDanhMucChinh] FROM [DANHMUCCHINH]">
                                <SelectParameters>
                                    <asp:Parameter DefaultValue="0" Name="Deleted" Type="Int32" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                            
                        </EditItemTemplate>
                        <HeaderTemplate>
                            Tên danh mục chính
                        </HeaderTemplate>
                        <ItemTemplate>
                            
                            <asp:DropDownList ID="DropDownList5" runat="server" 
                                DataSourceID="SqlDataSource1" DataTextField="TenDanhMucChinh" 
                                DataValueField="TenDanhMucChinh" Enabled="False" SelectedValue='<% # Bind("TenDanhMucChinh") %>'>
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
                                ProviderName="System.Data.SqlClient" 
                                SelectCommand="SELECT [TenDanhMucChinh] FROM [DANHMUCCHINH]">
                                <SelectParameters>
                                    <asp:Parameter DefaultValue="0" Name="Deleted" Type="Int32" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                            
                        </ItemTemplate>
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="ThuTuTrongDanhMucChinh" 
                        SortExpression="ThuTuTrongDanhMucChinh">
                        <EditItemTemplate>
                            <asp:DropDownList ID="DropDownList10" runat="server"
                                DataValueField="ThuTuTrongDanhMucChinh"
                                SelectedValue='<% # Bind("ThuTuTrongDanhMucChinh") %>'>
                                 <asp:ListItem>-1</asp:ListItem>
                                 <asp:ListItem>1</asp:ListItem>
                                 <asp:ListItem>2</asp:ListItem>
                                 <asp:ListItem>3</asp:ListItem>
                                 <asp:ListItem>4</asp:ListItem>
                                 <asp:ListItem>5</asp:ListItem>
                                 <asp:ListItem>6</asp:ListItem>
                                 <asp:ListItem>7</asp:ListItem>
                                 <asp:ListItem>8</asp:ListItem>
                                 <asp:ListItem>9</asp:ListItem>
                                 <asp:ListItem>10</asp:ListItem>
                                 <asp:ListItem>11</asp:ListItem>
                                 <asp:ListItem>12</asp:ListItem>
                                 <asp:ListItem>13</asp:ListItem>
                                 <asp:ListItem>14</asp:ListItem>
                                 <asp:ListItem>15</asp:ListItem>
                            </asp:DropDownList>
                        </EditItemTemplate>
                        <HeaderTemplate>
                            Thứ tự trong danh mục chính
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:DropDownList ID="DropDownList9" runat="server"
                                DataValueField="ThuTuTrongDanhMucChinh"
                                SelectedValue='<% # Bind("ThuTuTrongDanhMucChinh") %>' Enabled="false">
                                 <asp:ListItem>-1</asp:ListItem>
                                 <asp:ListItem>1</asp:ListItem>
                                 <asp:ListItem>2</asp:ListItem>
                                 <asp:ListItem>3</asp:ListItem>
                                 <asp:ListItem>4</asp:ListItem>
                                 <asp:ListItem>5</asp:ListItem>
                                 <asp:ListItem>6</asp:ListItem>
                                 <asp:ListItem>7</asp:ListItem>
                                 <asp:ListItem>8</asp:ListItem>
                                 <asp:ListItem>9</asp:ListItem>
                                 <asp:ListItem>10</asp:ListItem>
                                 <asp:ListItem>11</asp:ListItem>
                                 <asp:ListItem>12</asp:ListItem>
                                 <asp:ListItem>13</asp:ListItem>
                                 <asp:ListItem>14</asp:ListItem>
                                 <asp:ListItem>15</asp:ListItem>
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Đã xóa">
                        <EditItemTemplate>
                            <asp:DropDownList ID="DropDownList4" runat="server"
                             DataValueField="Deleted" SelectedValue='<% # Bind("Deleted") %>'>
                                <asp:ListItem>0</asp:ListItem>
                                <asp:ListItem>1</asp:ListItem>
                            </asp:DropDownList>
                        </EditItemTemplate>
                        <HeaderTemplate>
                            Đã xóa
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:DropDownList ID="DropDownList2" runat="server" Enabled="false"
                                SelectedValue='<% # Bind("Deleted") %>'>
                                <asp:ListItem>0</asp:ListItem>
                                 <asp:ListItem>1</asp:ListItem>
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateField>
                    
                </Columns>
            </asp:GridView>
            
		    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConflictDetection="CompareAllValues" 
                ConnectionString="<%$ ConnectionStrings:RAOVATConnectionString %>" 
                DeleteCommand="DELETE FROM [DANHMUCCON] WHERE [MaDanhMucCon] = @original_MaDanhMucCon AND (([TenDanhMucCon] = @original_TenDanhMucCon) OR ([TenDanhMucCon] IS NULL AND @original_TenDanhMucCon IS NULL)) AND (([MaDanhMucChinh] = @original_MaDanhMucChinh) OR ([MaDanhMucChinh] IS NULL AND @original_MaDanhMucChinh IS NULL)) AND (([ThuTuTrongDanhMucChinh] = @original_ThuTuTrongDanhMucChinh) OR ([ThuTuTrongDanhMucChinh] IS NULL AND @original_ThuTuTrongDanhMucChinh IS NULL)) AND (([Deleted] = @original_Deleted) OR ([Deleted] IS NULL AND @original_Deleted IS NULL))" 
                InsertCommand="INSERT INTO [DANHMUCCON] ([TenDanhMucCon], [MaDanhMucChinh], [ThuTuTrongDanhMucChinh], [Deleted]) VALUES (@TenDanhMucCon, @MaDanhMucChinh, @ThuTuTrongDanhMucChinh, @Deleted)" 
                OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT DANHMUCCON.MaDanhMucCon, DANHMUCCON.TenDanhMucCon, DANHMUCCHINH.TenDanhMucChinh, DANHMUCCON.ThuTuTrongDanhMucChinh, DANHMUCCON.Deleted FROM DANHMUCCON INNER JOIN DANHMUCCHINH ON DANHMUCCON.MaDanhMucChinh = DANHMUCCHINH.MaDanhMucChinh" 
                
                    
                    UpdateCommand="UPDATE [DANHMUCCON] SET [TenDanhMucCon] = @TenDanhMucCon, [MaDanhMucChinh] = @MaDanhMucChinh, [ThuTuTrongDanhMucChinh] = @ThuTuTrongDanhMucChinh, [Deleted] = @Deleted WHERE [MaDanhMucCon] = @original_MaDanhMucCon AND (([TenDanhMucCon] = @original_TenDanhMucCon) OR ([TenDanhMucCon] IS NULL AND @original_TenDanhMucCon IS NULL)) AND (([MaDanhMucChinh] = @original_MaDanhMucChinh) OR ([MaDanhMucChinh] IS NULL AND @original_MaDanhMucChinh IS NULL)) AND (([ThuTuTrongDanhMucChinh] = @original_ThuTuTrongDanhMucChinh) OR ([ThuTuTrongDanhMucChinh] IS NULL AND @original_ThuTuTrongDanhMucChinh IS NULL)) AND (([Deleted] = @original_Deleted) OR ([Deleted] IS NULL AND @original_Deleted IS NULL))">
                <DeleteParameters>
                    <asp:Parameter Name="original_MaDanhMucCon" Type="Int32" />
                    <asp:Parameter Name="original_TenDanhMucCon" Type="String" />
                    <asp:Parameter Name="original_MaDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="original_ThuTuTrongDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="original_Deleted" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="TenDanhMucCon" Type="String" />
                    <asp:Parameter Name="MaDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="ThuTuTrongDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="Deleted" Type="Int32" />
                    <asp:Parameter Name="original_MaDanhMucCon" Type="Int32" />
                    <asp:Parameter Name="original_TenDanhMucCon" Type="String" />
                    <asp:Parameter Name="original_MaDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="original_ThuTuTrongDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="original_Deleted" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="TenDanhMucCon" Type="String" />
                    <asp:Parameter Name="MaDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="ThuTuTrongDanhMucChinh" Type="Int32" />
                    <asp:Parameter Name="Deleted" Type="Int32" />
                </InsertParameters>
            </asp:SqlDataSource>
            
		</div>

            
            <div style="float:left">
               <asp:Label ID="Label2" runat="server" Text="Tên danh mục con"></asp:Label>
               <asp:TextBox ID="txtDanhMucCon" runat="server"></asp:TextBox>
               <asp:Button ID="Button2" runat="server" Text="Thêm mới" 
                   onclick="Button2_Click"/>
		   </div>
		</div>
        </div>
</div>
</asp:Content>
